package com.xcc.eureka.feign.control;

import com.xcc.bean.User;
import com.xcc.eureka.feign.client.BaseClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @outhor Ren
 * @create 2019-03-01 23:31
 * 描述:
 */
@RestController
public class FeignRestful {

    @Autowired
    private BaseClient mBaseClient;

    @Autowired
    private HttpServletRequest mServletRequest;

    @GetMapping("/getData")
    public String getEurekaClientData(String num) {
        System.out.println(num);
        System.out.println("get header: " + mServletRequest.getHeader("test"));
        return "通过 feign 调用 client 服务数据: " + mBaseClient.test(num);
    }

    @PostMapping(value = "/getObjData")
    @ResponseBody
    public User getEurekaClientObjData(@RequestBody User user) {
        return mBaseClient.getObj(user);
    }
}
